﻿package com.starz.games.scenes {
	import com.eaglesandcobras.games.scenes.*;
	import flash.events.*;
	import flash.display.*;
	import flash.utils.getDefinitionByName;
	import com.starz.games.questions.*;
	
	public class GameCutOne extends CutPage{
		private var _question:MovieClip;

		public function GameCutOne() {
			super();
		}
		
		override public function init():void {
			setOrder (passLevelCopy, showQuestionOne, showQuestionTwo, winLevel);
			
			//addSoundUpdate( soundHandler );
			//soundHandler();
		}
		
		
		/**************************
		IF VIDEO HANDLE MUTING AND PLAYING
		**************************/
		
		/*private function soundHandler():void {
			if ( soundOn ) {
				//content.videoP.video.volume = 1;
				//stopLoops();
			}else {
				content.videoP.video.volume = 0;
			}
		}*/
		
		/**************************
		PASS LEVEL
		**************************/
		public function passLevelCopy():void {
			content.passLevelClip.continueBtn.addEventListener(MouseEvent.CLICK, copyDone);
			content.passLevelClip.continueBtn.buttonMode = true;
		}
		
		private function copyDone(e:MouseEvent):void {
			content.passLevelClip.continueBtn.removeEventListener(MouseEvent.CLICK, copyDone);
			content.removeChild(content.passLevelClip);
			this.dispatchEvent(new Event (Event.COMPLETE));
		}
		
		/**************************
		QUESTION ONE
		**************************/
		public function showQuestionOne():void {
			_question = new QuestionOne();
			addChild( _question );
			_question.x = stage.stageWidth/2-_question.width/2;
			_question.y = stage.stageHeight/2-_question.height/2;
			
			_question.addEventListener( Event.COMPLETE, questionDone);
		}
		
		/**************************
		QUESTION TWO
		**************************/
		public function showQuestionTwo():void {
			_question = new QuestionOne();
			addChild( _question );
			_question.x = stage.stageWidth/2-_question.width/2;
			_question.y = stage.stageHeight/2-_question.height/2;
			
			_question.addEventListener( Event.COMPLETE, questionDone);
		}
		
		/**************************
		QUESTION DONE
		**************************/
		private function questionDone(e:Event):void {
			removeChild (DisplayObject ( e.target ));
			this.dispatchEvent( e );
		}
		
		
	}
	
}
